Ext.define('appmod.view.knowledge.TreeDashboard', {
    extend: 'Ext.panel.Panel',
    alias: ['widget.knowledge.treedashboard','widget.knowledge-treedashboard'],
    region : 'center',
    layout : {
		type:'border'
	},
	requires: [
		'appmod.view.knowledge.category.TreeGrid'
	],	
	border : false,
	margins:"5 5 5 5",

	constructor: function (config) {
		
		if (config.fieldStores) {
			this.stores = config.stores;
		}
        this.callParent(arguments);
     },	

    initComponent: function() {
        var me = this;
		
		// --- binding store ---
		var dsCategory = me.stores['category'];
	
        Ext.applyIf(me,{
			items:[
				{
					store:dsCategory,
			        rootVisible: true,
			        useArrows: true,
			        frame: true,
					title:'信息分类',
					collapsible:true,					
					xtype:'knowledge.tree.grid',
					region:'west',
					split:true,
					margins:"5 0 5 5",
					width:200
				},
				{
					xtype:'panel',
					region:'center',	
                    collapsed: false,
					layout:'border',
					autoScroll:true,
					margins:"5 5 5 0",
					items:[{
							margins:"5 5 5 5",
							plain:true,
							xtype:'tabpanel',
							region:'center'
						}			
					],
					dockedItems: [{
					    xtype: 'toolbar',
					    dock: 'top',
					    items: [
	                       {
	                            xtype: 'splitbutton',
	                            text: '新增',
	                            menu: {
	                                xtype: 'menu',
	                                width: 120,
	                                items: [
	                                    {
	                                        xtype: 'menuitem',
	                                        text: '新增知识点',
											action : 'addContent'
	                                    },
	                                    {
	                                        xtype: 'menuitem',
	                                        text: '上传附件',
											action : 'addAttachment'
	                                    }									
	                                ]
	                            }
	                        },
							{
								xtype:'button',
								text:'删除',
								action:'delete'
							},
							'-',
							{
								xtype:'combobox',
								fieldLabel:'显示格式',
								labelWidth:60,
								allowBlank:false,
								editable:false,
						        store: Ext.create('Ext.data.ArrayStore', {
							        fields: ['id', 'name'],
							        data : [
										['lecture','讲 稿'],
										['pic','图 片'],
										['km','综合知识']
									]
							    }),
							    displayField: 'name',
							    valueField: 'id',
								value:'lecture',						
						        typeAhead: true,
						        mode: 'local',
						        triggerAction: 'all',
						        emptyText:'显示分类',
						        selectOnFocus:true,
						        width:235						
							}
					    ]
					}]						
				}
			]
			
		});

        me.callParent(arguments);

    }
});